/**
*      author: Y_Yao
*      created: 2025-04-06 15:43:11
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 9e18;
const int INF = 0x3f3f3f3f;
const int N = 2e5 + 7;
string s1,s2;
int n;
vector<int> cnt1;
vector<int> cnt0;
int cnt1,cnto1,cntj0,cnto0;


void solve()
{
    cin >> n;
    cin >> s1;
    cin >> s2;
    cntj0 = cnto0 = cntj1 = cnto1 = 0;
    
    for(int i = 0;i < n;i++)
    {
        if(s1[i] == '1')
        {
            if(i % 2 == 0) cnto1++;
            else cntj1++;
        }
        if(s2[i] == '0')
        {
            if(i % 2 == 0) cnto0++;
            else cntj0++;
        }
    }

    if(cntj0 >= cnto1 && cnto0 >= cntj1)
    {
        cout << "YES" << endl;
        return;
    }
    cout << "NO" << endl;

}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    cin >> t;
    while(t--)
    {
        solve();
        cnt1.clear();
        cnt0.clear();
    }
    return 0;
}